package br.com.salao.velocity;

import java.io.StringWriter;
import java.util.Properties;

import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.VelocityEngine;


public class VelocityImp {

	public void generate(String pathTemplate, Object contexto){
		
		Properties props = new Properties();
        props.put("resource.loader", "class");
        props.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

        VelocityEngine ve = new VelocityEngine();
        ve.init(props);
        Template t = ve.getTemplate(pathTemplate);
        VelocityContext context = new VelocityContext();
        context.put("dados", contexto);

        StringWriter writer = new StringWriter();
        t.merge(context, writer);
      //  System.out.println(writer.toString());
	}
	
}
